package com.ztc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ztc.bean.ProjectModel;
import com.ztc.bean.StoreModel;
import com.ztc.dao.StoreDao;

/**
 * @类名：StoreService.java
 * @作者：李晓平
 * @时间：2018年7月25日 下午3:08:14
 * @描述：收藏service
 */
@Service
public class StoreService {

	@Autowired
	private StoreDao storeDao;
	
	@Autowired
	private ReportService reportService;
	
	/**
	 * 查询个人收藏
	 * @param store
	 * @return
	 */
	public List<StoreModel> queryStoreList(StoreModel store) {		
		return storeDao.queryStoreList(store);
	}
	
	/**
	 * 查询单个收藏明细
	 * @param id
	 * @return
	 * @throws Exception 
	 */
	public StoreModel queryOneStore(int id, int projectId, int authId) throws Exception {
		StoreModel storeModel = storeDao.queryOneStore(id);
		ProjectModel project = reportService.queryProjectById(projectId);
		String newContent = reportService.dealQuoteRule(project, authId, storeModel.getContent(), 1);
		storeModel.setContent(newContent);
		return storeModel;
	}
	
	/**
	 * 添加收藏
	 * @param store
	 * @return
	 */
	@Transactional
	public void addStore(StoreModel store) {
		storeDao.addStore(store);
	}
	
	/**
	 * 删除收藏
	 * @param id
	 */
	@Transactional
	public void deleteStore(int id) {
		storeDao.deleteStore(id);
	}
}
